package com.mk.auth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by yanzhiping on 2017/9/17.
 */
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Value("${location.static.path}")
    private String staticPath;

    @Value("${location.fileview.path}")
    private String fileViewPath;

    @Value("${location.imageview.path}")
    private String imageViewPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**","/file/view/**").addResourceLocations(staticPath,fileViewPath,imageViewPath);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("redirect:index.html");
    }
}
